// 拖动区域
MouseArea {
    id: dragArea

    property var item: parent

    anchors.left: parent.left
    anchors.right: parent.right
    anchors.top: parent.top
    anchors.bottom: parent.bottom

    hoverEnabled: true
    property var startPos: Qt.vector2d(0, 0)

    onPressed: function (mouse) {
        dragArea.startPos = Qt.vector2d(mouse.x, mouse.y);
    }

    onPositionChanged: function (mouse) {
        if (dragArea.pressed) {
            item.itemMoved();
            var delta = Qt.vector2d(mouse.x - startPos.x, mouse.y - startPos.y);
            item.x += delta.x;
            item.y += delta.y;
        }
    }
}